<template>
	<view class="car-list">
		<!-- <view class="header-nav">
			<view class="search">
				<uni-easyinput prefixIcon="search" @confirm="searchQuery" type="text" confirmType="search"
					v-model="params.value" placeholder="请输入vin搜索" @iconClick="iconClick" @clear="clearQuery">
				</uni-easyinput>
			</view>

		</view> -->

		<view class="uni-padding-wrap content">
			<view v-if="current === 0 && list.length">
				<contraList :showTip="false" :contract="item" v-for="item in list" :key="item.id"
					@tap="itemClick(item)">
				</contraList>
			</view>
			<Empty style="height: 100%;" v-else></Empty>
		</view>
	</view>
</template>

<script>
import {
	getContractRejections
} from '@/api/app.js'
import {
	getCurrentNowTime
} from '@/utils/index.js'
import carList from '@/components/testCar/index.vue'
import Empty from '@/components/empty/index.vue'
import contraList from '@/components/contratList/index.vue'
export default {
	components: {
		contraList,
		Empty
	},
	data() {
		return {
			current: 0,
			items: ['待检测', '已完结'],
			styleType: 'button',
			activeColor: '#409Eff',
			params: {},
			list: [],
			list2: [],
			id: '',
			name: '',
			olist: [],
			olist2: [],
			baseFormData: {},
			rules: {}
		}
	},
	onShow() {
		this.id = uni.getStorageSync('id')
		this.name = uni.getStorageSync('name')
		this.init()
	},
	methods: {
		async init() {
			let res = await getContractRejections({
				id: this.id
			})
			if (res.code == 0) {
				this.list = []
				this.list2 = []
			} else {
				this.list = res.data
				this.list2 = res.data
			}
		},
		iconClick(val) {
			console.log('iconClick', val);
		},
		searchQuery(val) {
			console.log(val, 'searchQuery');
			if (val) {
				this.list = this.list.filter(item => {
					return item.vin.includes(val)
				})
			}

		},
		clearQuery() {
			this.list = this.list2
		},
		itemClick(item) {
			console.log(item.id);
			const contract = uni.getStorageSync(item.id + '')
			console.log(contract);
			if (contract) {
				uni.navigateTo({
					url: `/pages/contractDetails/index?id=${contract.docTemplateId}&title=${contract.title}&reject=${item.id}`
				})
			} else {
				uni.showToast({
					title: '本地合同不存在：' + item.id,
					icon: 'none'
				})
			}
			// this.$refs.popup.open()
			// this.baseFormData = item
		},
		dialogClose() {
			console.log('点击关闭')
		}
	}
}
</script>

<style scoped lang="scss">
.car-list {
	padding-bottom: 20rpx;
	height: 100%;

	.header-nav {
		padding: 20rpx 0;
		background-color: #ffffff;

		.search {
			padding: 0 20rpx;
			margin-top: 10rpx;
		}

		.tabs {
			padding: 0 20rpx;
		}
	}

	@mixin flex {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
	}


	.content {
		padding: 20rpx;
	}

	.popup-content {
		padding: 30rpx;
		width: 600rpx;
		background-color: #fff;
	}
}
</style>